home *** CD-ROM | disk | FTP | other *** search
/ Acorn User: China / Acorn User China CD-ROM (UK) (Disc B) / Acorn User China CD-ROM (UK) (Disc B).bin / BARNET / ARMLINUX / MAIL / 9804 / text0032.txt < prev    next >
Encoding:
Text File  |  1998-05-13  |  2.5 KB  |  76 lines

  1. : Date: Sat, 11 Apr 1998 01:36:41 +0100 (BST)
  2. : From: Dave Gilbert <gilbertd@treblig.org>
  3. : Hi,
  4. :   In egcs-980406 (and earlier versions) the address offset range of the
  5. : ldrsb instruction (introduced in ARM architecture v4) is set to be the
  6. : same as normal ARM ldr (load register) instructions when it is actually
  7. : a lot smaller.  The following example excersises this:
  8. : ------------------------------------------------------------------------
  9. : struct foo {
  10. :   int padding[200];
  11. :   signed char toget;
  12. : };
  13. : signed char bar(struct foo* p) {
  14. :   return p->toget;
  15. : };
  16. : -------------------------------------------------------------------------
  17. : gcc -mcpu=strongarm110  egbug.c -O2
  18. : /tmp/cca06251.s: Assembler messages:
  19. : /tmp/cca06251.s:19: Error: address offset too large
  20. : _bar:
  21. :         @ args = 0, pretend = 0, frame = 0
  22. :         @ frame_needed = 1, current_function_anonymous_args = 0
  23. :         mov     ip, sp
  24. :         stmfd   sp!, {fp, ip, lr, pc}
  25. :         sub     fp, ip, #4
  26. :         ldrsb   r0, [r0, #800]     ******** Range should be +/- 255
  27. :         ldmea   fp, {fp, sp, pc}^
  28.  
  29. Applying this patch fixes the problem:
  30.  
  31. Index: arm.h
  32. ===================================================================
  33. RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/arm/arm.h,v
  34. retrieving revision 1.5
  35. diff -p -r1.5 arm.h
  36. *** arm.h    1998/04/08 06:19:00    1.5
  37. --- arm.h    1998/04/13 18:30:02
  38. *************** do                                    \
  39. *** 1408,1414 ****
  40.             && INTVAL (op) <= 31)                    \
  41.           goto LABEL;                            \
  42.           }                                \
  43. !       range = (MODE) == HImode ? (arm_arch4 ? 256 : 4095) : 4096;    \
  44.         if (code == CONST_INT && INTVAL (INDEX) < range            \
  45.         && INTVAL (INDEX) > -range)                            \
  46.           goto LABEL;                            \
  47. --- 1408,1416 ----
  48.             && INTVAL (op) <= 31)                    \
  49.           goto LABEL;                            \
  50.           }                                \
  51. !       /* NASTY: Since this limits the addressing of unsigned byte loads */      \
  52. !       range = ((MODE) == HImode || (MODE) == QImode)                    \
  53. !               ? (arm_arch4 ? 256 : 4095) : 4096;                        \
  54.         if (code == CONST_INT && INTVAL (INDEX) < range            \
  55.         && INTVAL (INDEX) > -range)                            \
  56.           goto LABEL;                            \
  57.  
  58. The code now produced looks like this:
  59.  
  60.   _bar:
  61.         mov     ip, sp
  62.         stmfd   sp!, {fp, ip, lr, pc}
  63.         mov     r3, #800
  64.         sub     fp, ip, #4
  65.         ldrsb   r0, [r0, r3]
  66.         ldmea   fp, {fp, sp, pc}
  67.  
  68. Nick
  69. unsubscribe: body of `unsubscribe linux-arm' to majordomo@vger.rutgers.edu
  70.  
  71.